using System;
using System.Collections.Generic;
using iPhOwa.Exchange.ContentClasses;
using iPhOwa.Exchange.ContentClasses.Fields;
using iPhOwa.Exchange.WebDav;
using iPhOwa.Exchange.WebDav.Methods;

namespace iPhOwa.Exchange.Managers
{
	/// <summary>
	/// Encapsulates working with person.
	/// </summary>
	public static class PersonManager
	{
		/// <summary>
		/// Get a list of persons.
		/// </summary>
		public static ICollection<Person> GetList(Uri path, OwaSession session)
		{
			string[] properties = new string[]
					{
							PersonFields.FileAs
							, PersonFields.Mobile
							, PersonFields.TelephoneNumber
					};

			Search search = new Search(path, session, properties);
			search.OrderBys.Add(new OrderBy(PersonFields.FileAs));

			List<Item> items = new List<Item>(search.Run());

			return items.ConvertAll<Person>(delegate(Item i)
			                                	{
			                                		return i as Person;
			                                	});
		}
	}
}